//
//  SISSUploadImageRemarkViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2019/7/5.
//  Copyright © 2019 优房网. All rights reserved.
//

#import "SISSUploadImageRemarkViewController.h"
#import "SISSUploadSuccessViewController.h"

@interface SISSUploadImageRemarkViewController ()

/// tipLabel
@property (weak, nonatomic) UILabel *tipLabel;
// 保存
@property (weak, nonatomic) UIButton *confirmButton;

@end

@implementation SISSUploadImageRemarkViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)setTipStr:(NSString *)tipStr {
    _tipStr = tipStr;
    self.tipLabel.text = tipStr;
}

// 确定按钮点击事件
- (void)confirmButtonClickAction {
    [self.view endEditing:YES];
    if (!self.uploadImageView.images || self.uploadImageView.images.count == 0) {
        [SISSTools showSVWithTitle:@"请选择图片"];
        return;
    }
    
}

- (void)pushToSuccessViewWithPopBackClassType:(SISSProgressPopBackClassType)popBackClassType {
    SISSUploadSuccessViewController *vc = [[SISSUploadSuccessViewController alloc] init];
    vc.popBackClassType = popBackClassType;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.containerView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    SISSUploadImageView *uploadImageView = [[SISSUploadImageView alloc] init];
    [self.containerView addSubview:uploadImageView];
    self.uploadImageView = uploadImageView;
    
    SISSLabelTextFieldView *remarkView = [[SISSLabelTextFieldView alloc] init];
    remarkView.leftStr = @"备注";
    remarkView.rightPlaceStr = @"请输入备注";
    remarkView.isShowBottomLine = YES;
    [self.containerView addSubview:remarkView];
    self.remarkView = remarkView;
    
    UILabel *tipLabel = [UILabel yyr_labelWithText:self.tipStr ? self.tipStr : nil fontSize:15 textColor:MAIN_TEXT_COLOR alignment:NSTextAlignmentLeft];
    [self.containerView addSubview:tipLabel];
    self.tipLabel = tipLabel;
    
    UIButton *confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [confirmButton setTitle:@"保存" forState:UIControlStateNormal];
    [confirmButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [confirmButton setBackgroundColor:MAIN_COLOR];
    [confirmButton addTarget:self action:@selector(confirmButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
    confirmButton.layer.cornerRadius = 4;
    confirmButton.layer.masksToBounds = YES;
    [self.containerView addSubview:confirmButton];
    self.confirmButton = confirmButton;
}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGSize buttonSize = CGSizeMake(SCREEN_WIDTH * 0.8, 54);
    
    [self.uploadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.containerView).offset(globelMargin);
        make.left.right.equalTo(weakSelf.containerView);
    }];
    
    [self.remarkView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.uploadImageView.mas_bottom).offset(2 * globelMargin);
        make.left.right.equalTo(weakSelf.containerView);
        make.height.mas_equalTo(5.5 * globelMargin);
    }];
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.remarkView.mas_bottom).offset(2 * globelMargin);
        make.left.right.equalTo(weakSelf.confirmButton);
    }];
    
    [self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.tipLabel.mas_bottom).offset(2 * globelMargin);
        make.centerX.equalTo(weakSelf.containerView.mas_centerX);
        make.size.mas_equalTo(buttonSize);
        make.bottom.equalTo(weakSelf.containerView).offset(-2 * globelMargin);
    }];
    
}


@end
